CREATE TABLE [dbo].[MatchingGift]
(
[MatchingGiftKey] [uniqueidentifier] NOT NULL,
[OriginalOrderLineKey] [uniqueidentifier] NOT NULL,
[MatchingOrderLineKey] [uniqueidentifier] NOT NULL,
[MatchingGiftPlanKey] [uniqueidentifier] NULL,
[MatchingGiftRelationshipKey] [uniqueidentifier] NULL,
[MatchingContactKey] [uniqueidentifier] NULL,
[MatchingGiftInfo] [nvarchar] (200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[MatchedAmount] [decimal] (18, 4) NOT NULL CONSTRAINT [DF_MatchingGift_MatchedAmount] DEFAULT ((0)),
[MarkedForDeleteOn] [datetime] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[MatchingGift] ADD CONSTRAINT [PK_MatchingGift] PRIMARY KEY CLUSTERED ([MatchingGiftKey]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[MatchingGift] ADD CONSTRAINT [AK_MatchingGift_OriginalDonationPartkey_MatchingDonationPartKey_MatchingGiftPlanKey] UNIQUE NONCLUSTERED ([OriginalOrderLineKey], [MatchingOrderLineKey], [MatchingGiftPlanKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_MatchingGift_MatchingContactKey] ON [dbo].[MatchingGift] ([MatchingContactKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_MatchingGift_MatchingGiftPlanKey] ON [dbo].[MatchingGift] ([MatchingGiftPlanKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_MatchingGift_MatchingDonationPartKey] ON [dbo].[MatchingGift] ([MatchingOrderLineKey]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[MatchingGift] ADD CONSTRAINT [FK_MatchingGift_ContactMain_Matching] FOREIGN KEY ([MatchingContactKey]) REFERENCES [dbo].[ContactMain] ([ContactKey])
GO
ALTER TABLE [dbo].[MatchingGift] ADD CONSTRAINT [FK_MatchingGift_MatchingGiftPlan] FOREIGN KEY ([MatchingGiftPlanKey]) REFERENCES [dbo].[MatchingGiftPlan] ([MatchingGiftPlanKey])
GO
ALTER TABLE [dbo].[MatchingGift] ADD CONSTRAINT [FK_MatchingGift_Relationship] FOREIGN KEY ([MatchingGiftRelationshipKey]) REFERENCES [dbo].[RelationshipMain] ([RelationshipKey])
GO